import javax.swing.*;
import java.awt.*;
import java.awt.event.WindowAdapter;
import java.awt.event.WindowEvent;
import java.util.ArrayList;
import java.util.zip.CheckedOutputStream;

public  class Chessboard extends JFrame {
    public JButton[][] add = new JButton[12][12];      //10*10棋盘
    public JButton ourJbutton = new JButton("我方先行");
    public JButton oppoisteJbutton = new JButton("电脑先行");
    public JButton regretJbutton = new JButton("悔棋");
    public JButton saveJbutton = new JButton("保存棋谱");
    public JButton endJbutton = new JButton("结束游戏");


    /*初始化窗口*/
    public void CFrame(){
        this.setTitle("阿渌的亚马逊棋");
        this.setVisible(true);
        this.setSize(1000,1000);
        this.setLocation(400,100);
        this.setResizable(false);

        /*结束虚拟机运行*/
        this.addWindowListener(new WindowAdapter() {
            @Override
            public void windowClosing(WindowEvent e) {
                System.exit(0);
            }
        });
    }

    /*画棋盘*/
    public void paintchess(){
        this.setLayout(new BorderLayout()); //设置边界管理
        JPanel centerPanel = new JPanel();
        JPanel westPanel =new JPanel();
        JPanel eastPanel = new JPanel();

        /*左边面板*/
        /*棋谱*/
        JTextArea addText = new JTextArea("棋谱",1,1);
        JTextArea Chesspu  = new JTextArea("这是亚马逊棋的棋谱",80,10);
        //textPanel.add(addText);
        westPanel.add(Chesspu);

        /*边界中间*/
        /*第一行*/
        centerPanel.setLayout(new GridLayout(12, 12,0,0));
        JLabel jLb5=new JLabel();
        char ch1 ='A';
        centerPanel.add(jLb5);
        for (int m = 0; m < 10; m++) {
            JLabel jLb3=new JLabel(Character.toString(ch1++),JLabel.CENTER);
            centerPanel.add(jLb3);
        }
        JLabel jLb6=new JLabel();
        centerPanel.add(jLb6);

        /*中间面板*/
        for (int i = 1; i < 11; i++) {
            JLabel jLb1=new JLabel(Integer.toString(11-i),JLabel.CENTER);
            centerPanel.add(jLb1);
            for (int j = 1; j < 11; j++) {
                    add[i][j] = new JButton();
                    add[i][j].setBackground(Color.white);
                centerPanel.add(add[i][j]);
            }
            JLabel jLb2=new JLabel(Integer.toString(11-i),JLabel.CENTER);
            centerPanel.add(jLb2);
        }

        /*最后一行*/
        JLabel jLb7=new JLabel();
        centerPanel.add(jLb7);
        char ch2 ='A';
        for (int n = 0; n < 10; n++) {
            JLabel jLb4=new JLabel(Character.toString(ch2++),JLabel.CENTER);
            centerPanel.add(jLb4);
        }
        JLabel jLb8=new JLabel();
        centerPanel.add(jLb8);

        add[1][4].setBackground(Color.red);
        add[1][7].setBackground(Color.red);
        add[4][1].setBackground(Color.red);
        add[4][10].setBackground(Color.red);

        add[7][1].setBackground(Color.blue);
        add[7][10].setBackground(Color.blue);
        add[10][4].setBackground(Color.blue);
        add[10][7].setBackground(Color.blue);

        /*右边面板*/
        eastPanel.setLayout(new GridLayout(5, 1,0,40));
        eastPanel.add(ourJbutton);
        eastPanel.add(oppoisteJbutton);
        eastPanel.add(regretJbutton);
        eastPanel.add(saveJbutton);
        eastPanel.add(endJbutton);


        Container contentPane = getContentPane();
        add(centerPanel,BorderLayout.CENTER);
        add(westPanel,BorderLayout.WEST);
        add(eastPanel,BorderLayout.EAST);


    }






}

